from .base import db
from datetime import datetime

class WorkExperience(db.Model):
    __tablename__ = 'work_experience'
    id = db.Column(db.Integer, primary_key=True)
    employee_id = db.Column(db.Integer, db.ForeignKey('employee.id'), nullable=False)
    company = db.Column(db.String(100), nullable=False)
    department = db.Column(db.String(100))
    position = db.Column(db.String(100))
    start_date = db.Column(db.String(20))
    end_date = db.Column(db.String(20))
    description = db.Column(db.Text)
    reason_for_leaving = db.Column(db.Text)
    reference = db.Column(db.String(100))
    reference_phone = db.Column(db.String(20))

    def to_dict(self):
        return {
            'id': self.id,
            'employee_id': self.employee_id,
            'company': self.company,
            'department': self.department,
            'position': self.position,
            'start_date': self.start_date,
            'end_date': self.end_date,
            'description': self.description,
            'reason_for_leaving': self.reason_for_leaving,
            'reference': self.reference,
            'reference_phone': self.reference_phone
        } 